import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          leading: Icon(Icons.star),
          title: Text("card"),
        ),
        body: ListView(
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: buildCard(),
            ),
            buildCard(),
            buildCard(),
            buildCard(),
            buildCard(),
            buildCard(),
            buildCard(),
          ],
        ));
  }

  Widget buildCard() {
    return Container(
      decoration: BoxDecoration(
        // container包起来设置圆角不起作用对card
        borderRadius: BorderRadius.all(Radius.circular(50)),
      ),
      child: Card(
        margin: EdgeInsets.all(10),
              child: Column(
                children: <Widget>[
                  Image.asset(
                    "assets/images/img1.jpg",
                    width: double.infinity,
                    height: 150,
                    fit: BoxFit.cover,
                  ),
                  Row(
                    children: <Widget>[
                      Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: Container(
                          child: Icon(Icons.star),
                        ),
                      ),
                      // Expanded填充剩余部分
                      Expanded(
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: <Widget>[
                            Text("aaa"),
                            Text(
                              "aaa",
                              style: TextStyle(fontSize: 12),
                            ),
                          ],
                        ),
                      ),
                      Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: Container(
                          child: Column(
                            children: <Widget>[
                              Icon(Icons.favorite),
                              Text(
                                "66",
                                style: TextStyle(fontSize: 12, color: Colors.red),
                              )
                            ],
                          ),
                        ),
                      )
                    ],
                  )
                ],
              ),
            ),
    );
  }
}
